package net.betou.cms.dao.main.impl;

import java.util.List;

import net.betou.cms.dao.main.CmsRoleDao;
import net.betou.cms.entity.main.CmsRole;
import net.betou.common.hibernate3.HibernateBaseDao;

import org.springframework.stereotype.Repository;

@Repository
public class CmsRoleDaoImpl extends HibernateBaseDao< CmsRole, Integer > implements CmsRoleDao{
	@SuppressWarnings( "unchecked" )
	public List< CmsRole > getList( ) {
		String hql = "from CmsRole bean order by bean.priority asc";
		return find( hql );
	}

	public CmsRole findById( Integer id ) {
		CmsRole entity = get( id );
		return entity;
	}

	public CmsRole save( CmsRole bean ) {
		getSession( ).save( bean );
		return bean;
	}

	public CmsRole deleteById( Integer id ) {
		CmsRole entity = super.get( id );
		if( entity != null ){
			getSession( ).delete( entity );
		}
		return entity;
	}

	@Override
	protected Class< CmsRole > getEntityClass( ) {
		return CmsRole.class;
	}
}